package com.shijie.controller.erp;

import com.shijie.core.Result;
import com.shijie.core.ResultGenerator;
import com.shijie.core.annotation.Log;
import com.shijie.core.annotation.RequiresPermissions;
import com.shijie.core.constants.PnConstant.BusinessType;
import com.shijie.domain.entity.Categories;
import com.shijie.service.CategoriesService;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/*
 *  用于erp编辑分类的节点
 *
 *  @author: smart boy
 *  @date: 2018-08-06
 *
 */
@RestController
@RequestMapping("/erp/categories")
public class CategoriesController {

    @Resource
	private CategoriesService categoriesService;

    @RequiresPermissions(value={"category:create"})
    @Log(title = "分类管理", action = BusinessType.INSERT)
	@PostMapping
    public Result add(@RequestBody Categories categories) {
        categoriesService.save(categories);
        return ResultGenerator.success();
	}
    
    @RequiresPermissions(value={"category:delete"})
    @Log(title = "分类管理", action = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        categoriesService.delete(id);
        return ResultGenerator.success();
	}

}

